package com.thoughtworks.biblioteca;

//Understands a movie that can be checked out from the library
class Movie {
	private String name;
	private String director;
	private String rating;

	public Movie(String name, String director, String rating) {
		this.name = name;
		this.director = director;
		this.rating = rating;
	}
	
	public Movie(String name, String director) {
		this.name = name;
		this.director = director;
		this.rating = "N/A";
	}

	public String getMovieName() {
		return name;
	}

	public String getMovieDirector() {
		return director;
	}

	public String getMovieRating() {
		return rating;
	}

	public void add() {
		new MovieDB().addMovie(this);
		
	}
	
	public void remove(){
		new MovieDB().removeMovie(this);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((director == null) ? 0 : director.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Movie other = (Movie) obj;
		if (director == null) {
			if (other.director != null)
				return false;
		} else if (!director.equals(other.director))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	
	
	

}
